//instanceof 的内部实现原理：类的原型是否在实例的 原型链上

function isInstanceOf(instance, klass){
    let proto = instance.__proto__;
    let prototype = klass.prototype;
    while(true){
        if(proto===null) return false;
        if(proto===prototype) return true;
        proto = proto.__proto__;
    }
}


class Parent{

}

class Child extends Parent{

}

const child = new Child();
console.log(isInstanceOf(child,Parent));
console.log(isInstanceOf(child,Child));
console.log(isInstanceOf(child, Array));